/*
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see http://www.gnu.org/licenses/. 
 *
 *  Authors:
 *  	Albert Marieges Garcia
 *  	Álex Pardo Fernández
 *  	Enric Mayas Márquez
 *  	Juan Carlos Calvo Tejedor
 *  	Marc Gironés Dezsényi
 *  
 *  Contact:
 *  	bcn.tours.android@gmail.com
 *  Webpage:
 *  	bcntours.co.cc
 *
 */
package com.BCNTours.AR.Vista;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.util.Log;
import android.widget.SeekBar;
import android.widget.TextView;

import com.BCNTours.R;

public class DistanceDialog extends Activity {

	
	@SuppressWarnings("unused")
	private int language;
	private int distance;
	@SuppressWarnings("unused")
	private int distResult;
	
	private SeekBar seekDistanceFilter;
	private TextView txtDistanceProgress;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
//		setContentView(R.layout.distance_filter_dialog);
		Dialog d = new Dialog(getApplicationContext());
		d.setContentView(R.layout.distance_filter_dialog);
	
		Bundle extras = getIntent().getExtras();
        language = extras.getInt("lang");
        distance = extras.getInt("dist");
		
		/*Find the component of the seekbar*/
		seekDistanceFilter = (SeekBar) findViewById(R.id.seekDistanceFilter);
		txtDistanceProgress = (TextView) findViewById(R.id.txtDistanceProgress);
		
		/*Set the parameters of the seekbar*/
		seekDistanceFilter.setMax(15);
		seekDistanceFilter.setProgress(distance);
		seekDistanceFilter.refreshDrawableState();
		txtDistanceProgress.setText(Integer.toString(distance));
		seekDistanceFilter.setOnSeekBarChangeListener(seekBarChangeListener);
	}	

	
	 /**
     * BtnActionListener of the main menu
     */
  /*  public void btnDistanceFilterPerformed(View view){
    	Intent intent = new Intent();
    	switch(view.getId()){
    		case R.id.btnDistanceOk:
    	        intent.putExtra("distance", distResult);
    	        setResult(1,intent);
    	        finish();
    			break;
    		
    		case R.id.btnDistanceCancel:
    			intent.putExtra("distance", distance);
    	        setResult(0,intent);
    			finish();
    			break;
    	}
    }*/
    
			
	/*
	 * Action listener of the seekbar.
	 */
    private SeekBar.OnSeekBarChangeListener seekBarChangeListener = new SeekBar.OnSeekBarChangeListener(){
	    
    	public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
	    // TODO Auto-generated method stub
    		
	    	txtDistanceProgress.setText(Integer.toString(progress));
	    	distResult = progress;
	    }
	    
	    public void onStartTrackingTouch(SeekBar seekBar) {
	    // TODO Auto-generated method stub
	    }
	
	    public void onStopTrackingTouch(SeekBar seekBar) {
	    // TODO Auto-generated method stub
	    	Log.i("change", "change(STOP)");
	    }
    };
	
   
//		//Set the message of the dialog
//		switch(language){
//			case 1: //Spanish
//				txtDist.setText("Selecciona la distancia maxima a mostrar");
//				btnOK.setText("Aceptar");
//				btnNO.setText("Cancelar");
//				break;
//			case 2: //Catalan
//				txtDist.setText("Selecciona la distància màxima a mostrar");
//				btnOK.setText("Acceptar");
//				btnNO.setText("Cancelar");
//				break;
//				
//			default: //English by default
//				txtDist.setText("Select the maximum distance to be desplayed");
//				btnOK.setText("Ok");
//				btnNO.setText("Cancel");
//				break;
//		}
}